# Author    :Dun_Hz
# Time      :2024/3/18 11:25
# 用列表实现栈，列表的末端设置为栈顶
class Stack:
    def __init__(self):
        self.items = []

    def isEmpty(self):
        return self.items == []

    def push(self, item):
        self.items.append(item)

    def pop(self):
        return self.items.pop()

    def peek(self):
        if self.size()>0:
            return self.items[-1]
        else:
            return None

    def size(self):
        return len(self.items)

if __name__ == '__main__':
    s = Stack()
    print(s.isEmpty())
    s.push(4)
    s.push('dog')
    print(s.peek())
    s.push(True)
    print(s.size())
    print(s.isEmpty())
    s.pop()
    print(s.pop())
    print(s.size())